package com.example.starseas_phone;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


public class ImformationActivity extends AppCompatActivity {

    private ImageView information_touxiang;

    private LinearLayout imformation_Stu;
    private LinearLayout imformation_Tea;
    private LinearLayout imformation_Dept;

    private TextView information_StuName;
    private TextView information_StuNational;
    private TextView information_StuId;
    private TextView information_StuSex;
    private TextView information_StuAge;
    private TextView information_StuPoliticalLandscape;
    private TextView information_StuNativePlace;
    private TextView information_Stucarid;
    private TextView information_StuPhone;
    private TextView information_StuEmail;
    private TextView information_StuTheCounselorName;
    private TextView information_CollegeName;
    private TextView information_ProfessionalName;
    private TextView information_StuClassId;
    private TextView information_Grade;
    private TextView information_StubackTime;

    private TextView information_TeaName;
    private TextView information_TeaId;
    private TextView information_TeaSex;
    private TextView information_TeaAge;
    private TextView information_WorkerCarid;
    private TextView information_WorkerPhone;
    private TextView information_WorkerEmail;
    private TextView information_WorkerLocal;
    private TextView information_TeaClassId;
    private TextView information_TeaCollegeName;
    private TextView information_TeaProfessionalName;
    private TextView information_TeaBackTime;

    private TextView information_DeptName;
    private TextView information_DeptId;
    private TextView information_DeptSex;
    private TextView information_DeptAge;
    private TextView information_DeptCarid;
    private TextView information_DeptPhone;
    private TextView information_DeptEmail;
    private TextView information_DeptLocal;
    private TextView information_DeptBackTime;

    private Button imformation_btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_imformation);
        Intent intent = getIntent();
        String id = intent.getStringExtra("id");
        initid();
        if (Sto.State==1){
            imformation_Dept.setVisibility(View.GONE);
            imformation_Stu.setVisibility(View.VISIBLE);
            imformation_Tea.setVisibility(View.GONE);
            Stuinitview();
        }else {
            if (id.equals("6")){
                imformation_Dept.setVisibility(View.VISIBLE);
                imformation_Stu.setVisibility(View.GONE);
                imformation_Tea.setVisibility(View.GONE);
                Deptinitview();
            }else {
                imformation_Dept.setVisibility(View.GONE);
                imformation_Stu.setVisibility(View.GONE);
                imformation_Tea.setVisibility(View.VISIBLE);
                Teainitview();
            }
        }

        imformation_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (Sto.State==1){
                    Intent intent = new Intent(ImformationActivity.this,Modify_the_Stu.class);
                    startActivity(intent);
                }else {
                    if (id.equals("6")){
                        Intent intent = new Intent(ImformationActivity.this,Modify_the_Dept.class);
                        startActivity(intent);
                    }else {
                        Intent intent = new Intent(ImformationActivity.this,Modify_the_Tea.class);
                        startActivity(intent);
                    }

                }
            }
        });
    }

    private void initid(){
        information_touxiang = (ImageView) findViewById(R.id.information_touxiang);

        imformation_Stu = (LinearLayout) findViewById(R.id.imformation_Stu);
        imformation_Tea = (LinearLayout) findViewById(R.id.imformation_Tea);
        imformation_Dept = (LinearLayout) findViewById(R.id.imformation_Dept);


        information_StuName = (TextView) findViewById(R.id.information_StuName);
        information_StuNational = (TextView) findViewById(R.id.information_StuNational);
        information_StuId = (TextView) findViewById(R.id.information_StuId);
        information_StuSex = (TextView) findViewById(R.id.information_StuSex);
        information_StuAge = (TextView) findViewById(R.id.information_StuAge);
        information_StuPoliticalLandscape = (TextView) findViewById(R.id.information_StuPoliticalLandscape);
        information_StuNativePlace = (TextView) findViewById(R.id.information_StuNativePlace);
        information_Stucarid = (TextView) findViewById(R.id.information_Stucarid);
        information_StuPhone = (TextView) findViewById(R.id.information_StuPhone);
        information_StuEmail = (TextView) findViewById(R.id.information_StuEmail);
        information_StuTheCounselorName = (TextView) findViewById(R.id.information_StuTheCounselorName);
        information_CollegeName = (TextView) findViewById(R.id.information_CollegeName);
        information_ProfessionalName = (TextView) findViewById(R.id.information_ProfessionalName);
        information_StuClassId = (TextView) findViewById(R.id.information_StuClassId);
        information_Grade = (TextView) findViewById(R.id.information_Grade);
        information_StubackTime = (TextView) findViewById(R.id.information_StubackTime);

        information_TeaName = (TextView) findViewById(R.id.information_TeaName);
        information_TeaId = (TextView) findViewById(R.id.information_TeaId);
        information_TeaSex = (TextView) findViewById(R.id.information_TeaSex);
        information_TeaAge = (TextView) findViewById(R.id.information_TeaAge);
        information_WorkerCarid = (TextView) findViewById(R.id.information_WorkerCarid);
        information_WorkerPhone = (TextView) findViewById(R.id.information_WorkerPhone);
        information_WorkerEmail = (TextView) findViewById(R.id.information_WorkerEmail);
        information_WorkerLocal = (TextView) findViewById(R.id.information_WorkerLocal);
        information_TeaClassId = (TextView) findViewById(R.id.information_TeaClassId);
        information_TeaCollegeName = (TextView) findViewById(R.id.information_TeaCollegeName);
        information_TeaProfessionalName = (TextView) findViewById(R.id.information_TeaProfessionalName);
        information_TeaBackTime = (TextView) findViewById(R.id.information_TeaBackTime);

        information_DeptName = (TextView) findViewById(R.id.information_DeptName);
        information_DeptId = (TextView) findViewById(R.id.information_DeptId);
        information_DeptSex = (TextView) findViewById(R.id.information_DeptSex);
        information_DeptAge = (TextView) findViewById(R.id.information_DeptAge);
        information_DeptCarid = (TextView) findViewById(R.id.information_DeptCarid);
        information_DeptPhone = (TextView) findViewById(R.id.information_DeptPhone);
        information_DeptEmail = (TextView) findViewById(R.id.information_DeptEmail);
        information_DeptLocal = (TextView) findViewById(R.id.information_DeptLocal);
        information_DeptBackTime = (TextView) findViewById(R.id.information_DeptBackTime);

        imformation_btn = (Button) findViewById(R.id.imformation_btn);
    }

    private void Stuinitview(){
        //修改头像
        if (Sto.students.getStuSex().equals("男")){
            information_touxiang.setBackgroundResource(R.drawable.man_student);
        }else {
            information_touxiang.setBackgroundResource(R.drawable.women_student);
        }

        //修改名字
        information_StuName.setText(Sto.students.getStuName());
        //修改名族
        information_StuNational.setText(Sto.students.getNational());
        //修改学号
        information_StuId.setText(Sto.students.getStuId());
        //修改性别
        information_StuSex.setText(Sto.students.getStuSex());
        //修改年龄
        information_StuAge.setText(Sto.students.getStuAge()+"");
        //修改政治面貌
        information_StuPoliticalLandscape.setText(Sto.students.getPoliticalLandscape());
        //修改籍贯
        information_StuNativePlace.setText(Sto.students.getNativePlace());
        //修改身份证
        information_Stucarid.setText(Sto.students.getStuCarid());
        //修改手机号
        information_StuPhone.setText(Sto.students.getStuPhone());
        //修改邮箱
        information_StuEmail.setText(Sto.students.getStuEmail());
        //修改辅导员
        information_StuTheCounselorName.setText(Sto.students.getTheCounselorName());
        //修改学院
        information_CollegeName.setText(Sto.students.getCollegeName());
        //修改专业
        information_ProfessionalName.setText(Sto.students.getProfessionalName());
        //修改班级
        information_StuClassId.setText(Sto.students.getStuClassId());
        //修改年级
        information_Grade.setText(Sto.students.getGrade());
        //修改开学时间
        information_StubackTime.setText(Sto.students.getStubackTime());
    }

    private void Teainitview(){
        //修改头像
        if (Sto.teachers.getWorkerSex().equals("男")){
            information_touxiang.setBackgroundResource(R.drawable.man_teacher);
        }else {
            information_touxiang.setBackgroundResource(R.drawable.women_teacher);
        }

        //修改名字
        information_TeaName.setText(Sto.teachers.getWorkerName());
        //修改学号
        information_TeaId.setText(Sto.teachers.getWorkerId());
        //修改性别
        information_TeaSex.setText(Sto.teachers.getWorkerSex());
        //修改年龄
        information_TeaAge.setText(Sto.teachers.getWorkerAge()+"");
        //修改身份证
        information_WorkerCarid.setText(Sto.teachers.getWorkerCarid());
        //修改身份证
        information_WorkerPhone.setText(Sto.teachers.getWorkerPhone());
        //修改身份证
        information_WorkerEmail.setText(Sto.teachers.getWorkerEmail());
        //修改身份证
        information_WorkerLocal.setText(Sto.teachers.getWorkerLocal());
        //修改身份证
        information_TeaClassId.setText(Sto.teachers.getClassId());

        //修改学院
        information_TeaCollegeName.setText(Sto.teachers.getCollegeName());
        //修改专业
        information_TeaProfessionalName.setText(Sto.teachers.getProfessionalName());
        //修改入职时间
        String str=Sto.teachers.getWorkerbackTime();

        str=str.substring(0,10);
        information_TeaBackTime.setText(str);

    }

    private void Deptinitview(){
        //修改头像
        if (Sto.dept.getWorkerSex().equals("男")){
            information_touxiang.setBackgroundResource(R.drawable.man_teacher);
        }else {
            information_touxiang.setBackgroundResource(R.drawable.women_teacher);
        }

        //修改名字
        information_DeptName.setText(Sto.dept.getWorkerName());
        //修改学号
        information_DeptId.setText(Sto.dept.getWorkerId());
        //修改性别
        information_DeptSex.setText(Sto.dept.getWorkerSex());
        //修改年龄
        information_DeptAge.setText(Sto.dept.getWorkerAge()+"");
        //修改身份证
        information_DeptCarid.setText(Sto.dept.getWorkerCarid());
        //修改身份证
        information_DeptPhone.setText(Sto.dept.getWorkerPhone());
        //修改身份证
        information_DeptEmail.setText(Sto.dept.getWorkerEmail());
        //修改身份证
        information_DeptLocal.setText(Sto.dept.getWorkerLocal());
        //修改入职时间
        String str=Sto.dept.getWorkerbackTime();

        str=str.substring(0,10);
        information_DeptBackTime.setText(str);
    }

}